﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.ComponentModel;
using System.Collections.ObjectModel;
using Halfwit.Pollers;
using System.Windows.Threading;
using TweetSharp.Twitter.Extensions;
using TweetSharp.Twitter.Fluent;
using TweetSharp.Twitter.Model;

namespace Halfwit.ViewModels
{
    public class HomeViewModel : TweetsViewModel
    {
        public HomeViewModel(MainViewModel host)
            : base(host)
        {
            Pollers.Add(new HomePoller(PollCompleted));
            Pollers.Add(new MentionsPoller(PollCompleted));
            Pollers.Add(new MessagesPoller(PollCompleted));
            Pollers.Add(new SearchPoller(() => Properties.Settings.Default.HomeSearchPhrase, PollCompleted));
        }

        protected override void OnUpdate(TwitterResult result)
        {
            var status = result.AsStatus();
            if (status == null) return;
            if (Tweets.Any(t => t.Id == status.Id)) return;

            Tweets.Add(status);
        }
    }
}
